Clarify the default `cargo run` error message on a non-zero exit code
authorGleb Kozyrev <gleb@gkoz.com>
Tue, 13 Oct 2015 00:31:57 +0000 (03:31 +0300)
committerGleb Kozyrev <gleb@gkoz.com>
Tue, 13 Oct 2015 00:31:57 +0000 (03:31 +0300)
The behavior is the same in the default and verbose modes now:
 - the default mode will not suggest re-running with `--verbose`
 - the verbose mode will not print the binary name.

src/bin/run.rs
tests/test_cargo_run.rs

index 2483dcc8dfc14b390b28694e82bde6994349783d..838ac4655f93cbfd9aeba7561e46dfa3755df5a8 100644 (file)
@@ -1,5 +1,5 @@
 use cargo::ops;
-use cargo::util::{CliResult, CliError, Config};
+use cargo::util::{CliResult, CliError, Config, human};
 use cargo::util::important_paths::{find_root_manifest_for_cwd};
 
 #[derive(RustcDecodable)]
@@ -92,7 +92,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
         None => Ok(None),
         Some(err) => {
             Err(match err.exit.as_ref().and_then(|e| e.code()) {
-                Some(i) => CliError::from_error(err, i),
+                Some(code) => {
+                    let desc = format!("Process finished with exit status {}", code);
+                    CliError::from_boxed(human(desc), code)
+                }
                 None => CliError::from_error(err, 101),
             })
         }
index 3ad49c418542c06fec00f347d6ab638d9139abea..f2dab301cb3cb9a1ab2931f1e83c140dc2a72dc9 100644 (file)
@@ -102,7 +102,11 @@ test!(exit_code {
         "#);
 
     assert_that(p.cargo_process("run"),
-                execs().with_status(2));
+                execs().with_status(2)
+                       .with_stderr(&format!("\
+Process finished with exit status 2
+",
+        )));
 });
 
 test!(exit_code_verbose {
@@ -120,7 +124,7 @@ test!(exit_code_verbose {
     assert_that(p.cargo_process("run").arg("-v"),
                 execs().with_status(2)
                        .with_stderr(&format!("\
-Process didn't exit successfully: `target[..]foo` (exit code: 2)
+Process finished with exit status 2
 ",
         )));
 });